﻿#include <QFile>
#include "qloggerfileappender.hpp"

void QLoggerFileAppender::write (const QLoggerEvent &event)
{
    QMutexLocker lock(&mutex);
    QFile file(_filename);
    if (file.open(QFile::WriteOnly | QFile::Append))
        {
            QTextStream out(&file);
            out.setCodec(_codec);
            streamWrite(out, event);
            file.close();
        }
}

QLoggerFileAppender::QLoggerFileAppender (int level, const QString &filename,
                                          const QString &format,
                                          const QString& time_format) :
QLoggerAppender(format, level, time_format)
{
    _filename = filename;
}
